/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package simframe.simulation;

/**
 *
 * @author Steve Noble
 *
 */
public final class Time {

    public static interface Next {
        long getNext(long t);
    }

    public static final long Day = 86400000;
    public static final long Hour = 3600000;

    static public enum Period {
        None(-1),
        Daily(Day),
        Weekly(7 * Day),
        Quarterly(91 * Day);

        private final long tics;
        Period(long tics) { this.tics = tics; }
        public long getTics() { return tics; }
    }

    static public long getDay(long tics) {
        return tics/Day;
    }

    static public long getHour(long tics) {
        return (tics % Day)/Hour;
    }

    static public Long next(long tics, Time.Period period) {
        if (period == Time.Period.None) {
            return null;
        }
        
        return tics + period.getTics();
    }

    static public String toString(Long tics) {
        long day = tics/Time.Day;
        long hour = (tics - day * Time.Day)/Time.Hour;

        return "Day: " + Long.toString(day) + " Hour: " + Long.toString(hour);
    }
}
